package cn.xiaopengstack.domain.trade.rule.factory;

import cn.xiaopengstack.domain.trade.rule.settlement.EndNodeFilter;
import cn.xiaopengstack.domain.trade.rule.settlement.SCRuleFilter;
import cn.xiaopengstack.domain.trade.rule.settlement.SettlementValidateFilter;
import cn.xiaopengstack.domain.trade.rule.settlement.TradeOrderValidateFilter;
import cn.xiaopengstack.domain.trade.model.entity.GroupBuyOrderEntity;
import cn.xiaopengstack.domain.trade.model.entity.MarketOrderEntity;
import cn.xiaopengstack.domain.trade.model.entity.SettlementRuleCommandEntity;
import cn.xiaopengstack.domain.trade.model.entity.SettlementRuleResponseEntity;
import cn.xiaopengstack.types.framework.strategy.link.mutilModel.BusinessLinkedList;
import cn.xiaopengstack.types.framework.strategy.link.mutilModel.LinkArmory;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author jiangyangang
 */
@Component
@Slf4j
public class SettlementRuleFilterFactory {


    @Bean("tradeSettlementRuleFilter")
    public BusinessLinkedList<SettlementRuleCommandEntity, DynamicContext, SettlementRuleResponseEntity> tradeSettlementRuleFilter(
            SCRuleFilter scRuleFilter,
            TradeOrderValidateFilter tradeOrderValidateFilter,
            SettlementValidateFilter settlementValidateFilter,
            EndNodeFilter endNodeFilter
    ){
        return new LinkArmory<>("交易结算规则过滤链",
                scRuleFilter,
                tradeOrderValidateFilter,
                settlementValidateFilter,
                endNodeFilter)
                .getLogicLink();
    }

    @Data
    public static class DynamicContext{

        private MarketOrderEntity marketOrderEntity;


        private GroupBuyOrderEntity groupBuyOrderEntity;
    }
}
